package ua.kharkov.knure.dereza.summarytask4.db.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import ua.kharkov.knure.dereza.summarytask4.db.dto.ClientDTO;

/**
 * Basic interface for all ClientDAO
 * 
 * @author dereza
 * 
 */
public interface ClientDAO {
   
	/**
	 * Returns a client with the given id
	 * 
	 * @param client id
	 * @return ClientDTO
	 */
	public ClientDTO findClientById(int id);
	
	/**
	 * Returns a client with the given card id
	 * 
	 * @return ClientDTO
	 */
	public ClientDTO findClientByCardId(int cardId);
	
	/**
	 * Returns a client with the given login
	 * 
	 * @param login
	 * @return ClientDTO
	 */
	public ClientDTO findClientByLogin(String login);
	
	/**
	 * Updates information about client
	 * 
	 * @param clientDTO
	 */
	public void updateClient(ClientDTO clientDTO);
	
	/**
	 * Extracts ClientDTO from given ResultSet
	 * 
	 * @param rs
	 * @return ClientDTO
	 * @throws SQLException
	 */
	public ClientDTO extractClientDTO(ResultSet rs) throws SQLException;

	/**
	 * Commits query and closes connection
	 * 
	 * @param rs
	 * @param ps
	 * @param conn
	 */
	public void commitAndClose(ResultSet rs, Statement ps, Connection conn);

	/**
	 * Rolls back the request
	 * 
	 * @param conn
	 */
	public void rollback(Connection conn);
}